/**
 * JavaScript Document
 * @author sijian zhang
 */

$sj.boxClass = {
    messige : function(msg , title , cla , bgcolor , Opacity , close){
		if(bgcolor != "none"){
			ifm = $sj.boxClass.ifmBackground(bgcolor , Opacity);
		}
		else{
			$sj.init()
		}
		iDiv = document.createElement("div")
		iDiv.className = cla || "messige";
		if(title){
			iTitle = document.createElement("H6")
			iTitle.innerHTML = title;
			iDiv.appendChild(iTitle)
		}
		iCon = document.createElement("P")
		iCon.innerHTML = msg;
		ibutton = document.createElement("button")
		ibutton.innerHTML = "close" || close
		ibutton.onclick = function(){
			iDiv.parentNode.removeChild(iDiv)
			try{
				ifm.parentNode.removeChild(ifm)
			}
			catch(e){
				return
			}
		}
		iDiv.appendChild(iCon)
		iDiv.appendChild(ibutton)
		BODY.appendChild(iDiv)
		iDiv.style.left = $sj.util.getObjWidth(DOC)/2 - $sj.util.getObjWidth(iDiv)/2 + "px";
		iDiv.style.top = $sj.util.getObjHeight(DOC)/2 - $sj.util.getObjHeight(iDiv) + "px";
		
	},
	ifmBackground : function(color , Opacity , id ){
		color = color || "#000000";
		Opacity = Opacity || "50"
		$sj.init()
		ifm = document.createElement("iframe");
		ifm.id = id || "ifmBg"
		ifm.setAttribute("frameBorder", "0")
		ifm.style.zIndex = 1;
		ifm.style.width = $sj.util.getObjWidth(DOC) + "px"
		ifm.style.height = $sj.util.getObjHeight(DOC) + "px"
		ifm.style.position = "absolute";
		ifm.style.left = 0;
		ifm.style.top = 0;
		ifm.style.right = 0;
		ifm.style.bottom = 0;
		$sj.util.setOpacity(Opacity , ifm)	
		BODY.appendChild(ifm)
		ifmDoc = $sj.getIframeDoc(ifm.id)
		ifmDoc.designMode = "On"
		ifmDoc.open();
	    ifmDoc.write("<html><head></head><body style='background:" + color + "' oncontextmenu='javascript:return false'></body></html>");
	    ifmDoc.close();
		ifmDoc.designMode = "Off"
		return ifm
	},
	showBox : function(id , bgcolor , Opacity){
		if(bgcolor != "none"){
			$sj.boxClass.ifmBackground(bgcolor , Opacity);
		}
		else{
			$sj.init()
		}
		
		iBox = document.getElementById(id);
		iBox.style.display = "";
		iBox.style.visibility = "";
		iBox.style.position = "absolute";
		iBox.style.left = $sj.util.getObjWidth(DOC)/2 - $sj.util.getObjWidth(iBox)/2 + "px";
		iBox.style.top = $sj.util.getObjHeight(DOC)/2 - $sj.util.getObjHeight(iBox) + "px";
	},
	hiddenBox : function(id){
		iBox = document.getElementById(id);
		iBox.style.visibility = "hidden";
		try{
			ifm.parentNode.removeChild(ifm)
		}
		catch(e){
			return
		}
	},
	win : function(eventId , showId , hiddenId , eventType , bgcolor , Opacity){
		show = function(){
			$sj.boxClass.showBox(showId , bgcolor , Opacity)
		}
		hidden  = function(){
			$sj.boxClass.hiddenBox(showId)
		}
		eventType = eventType || "click"
		$sj.util.addEvent(eventType , show , eventId , bgcolor , Opacity)
		$sj.util.addEvent(eventType , hidden , hiddenId , bgcolor , Opacity)
	},
	addIframe: function(ids , url , w , h){
		ifw = w || "auto" ;
		ifh = h || "auto" ;
		$obj(ids).innerHTML = "<iframe" + " src='" + url  +  "'width='" + ifw + "' height = '" + ifh + "'frameBorder = '0'></iframe>";
	}
	
}

